<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="css/page.css" type="text/css" rel="stysheet">
<?php
require_once '../ptnhuan-web1/data/users.php';
?>
<form method="POST">
    User name: <input type="text" name="username">
    Password: <input type="password" name="password">
    <input type="submit" name="submit">
</form>
<?php if (isset($_POST['submit'])): ?>
    <?php
    $username = $_POST['username'];
    $password = $_POST['password'];
    $isOk = FALSE;
    $index = -1;

    for ($i = 0; $i < count($users); $i++) {
        if ((strcmp($users[$i]['username'], $users) == 0 ) &&
                (strcmp($users[$i]['password'], $password) == 0)) {
            $isOk = TRUE;
            $index = $i;
        }
    }
    if ($isOk) {
        header("Location: http://localhost/ptnhuan-web1/films.php?uid=" . $users[$index]['id']);
    } else {
        echo 'dang nhap that bai';
    }
    ?>
<?php endif; ?>

